cmake_minimum_required(VERSION 3.22)
project(nanok)

set(CMAKE_CXX_STANDARD 20)

# 查找依赖
find_package(PkgConfig REQUIRED)
pkg_check_modules(MHD libmicrohttpd REQUIRED)
pkg_check_modules(JSONCPP jsoncpp REQUIRED)
pkg_check_modules(CURL libcurl REQUIRED)



# 添加模块搜索路径
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
# 查找 LevelDB
find_package(LevelDB REQUIRED)
# 包含头文件目录
# include_directories(${LEVELDB_INCLUDE_DIRS})
# find_package(LevelDB REQUIRED)

# 日志记录
add_subdirectory(tpps/spdlog)
# 单元测试库
add_subdirectory(tpps/googletest)
# 添加核心库
add_subdirectory(src/core)

# 包含目录
include_directories(include)
include_directories(tpps/spdlog/include)
include_directories(tpps/googletest/googletest/include)
include_directories(${MHD_INCLUDE_DIRS})
include_directories(${JSONCPP_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${LevelDB_INCLUDE_DIRS})

# 添加可执行文件
add_executable(nanok
    src/main.cpp
)

# 链接库
target_link_libraries(nanok
    ${MHD_LIBRARIES}
    ${JSONCPP_LIBRARIES}
    ${CURL_LIBRARIES}
    ${LEVELDB_LIBRARIES}
    pthread
    spdlog::spdlog
    nanok_core_lib
)

# 安装目标
install(TARGETS nanok DESTINATION bin)